#define layout()
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>#(projectName)</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <link rel="stylesheet" type="text/css" href="#(ctx)/css/bootstrap.min.css" media="all">
    <link rel="stylesheet" type="text/css" href="#(ctx)/css/app.css" media="all">
    <!--    <link rel="icon" type="image/png" href="#(ctx)/static/dist/style/res/logo.png">-->
    #@css?()
</head>
<body style="background-color: #(backgroundColor)">
    #@main()
    
    <div id="toast" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-body text-center text-white">
                    <i></i>
                    <div id="toast-content"></div>
                </div>
            </div>
        </div>
    </div>
    
    <script type="text/javascript" src="#(ctx)/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="#(ctx)/js/popper.min.js"></script>
    <script type="text/javascript" src="#(ctx)/js/bootstrap.min.js"></script>
    
    <script type="text/javascript">
        Date.prototype.format = function(format) {
            /* 
             * 使用例子:format="yyyy-MM-dd hh:mm:ss"; 
             */
            const o = {
                "M+" : this.getMonth() + 1, // month 
                "d+" : this.getDate(), // day 
                "h+" : this.getHours(), // hour 
                "m+" : this.getMinutes(), // minute 
                "s+" : this.getSeconds(), // second 
                "q+" : Math.floor((this.getMonth() + 3) / 3), // quarter 
                "S" : this.getMilliseconds()
                // millisecond 
            };

            if (/(y+)/.test(format)) {
                format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            }

            for (let k in o) {
                if (new RegExp("(" + k + ")").test(format)) {
                    format = format.replace(RegExp.$1, RegExp.$1.length == 1
                        ? o[k]
                        : ("00" + o[k]).substr(("" + o[k]).length));
                }
            }
            return format;
        };
        const utils = {
            isShownToast: false,
            isPC: function() {
                const userAgentInfo = navigator.userAgent;
                const Agents = ["Android", "iPhone", "iPad"];
                let flag = true;
                for (let i = 0; i < Agents.length; i++) {
                    if (userAgentInfo.indexOf(Agents[i]) > 0) {
                        flag = false;
                        break;
                    }
                }
                return flag;
            },
            formValue: function(form) {
                let result = {};
                const values = form.serializeArray();
                $.each(values, function(i, item) {
                    result[item.name] = item.value;
                });
                return result;
            },
            showToast: function(text, icon = "", autoHide = false, callback) {
                $("#toast-content").text(text);
                if (icon && icon != "") {
                    $("#toast i").addClass("weui-" + icon).show();
                    $("#toast .modal-content").addClass("modal-icon-content");
                } else {
                    $("#toast .modal-content").removeClass("modal-icon-content");
                    $("#toast i").hide();
                }

                if (!this.isShownToast) {
                    $("#toast").modal('show');
                    this.isShownToast = true;
                }
                
                if (autoHide) return utils.hideToast(1500, callback);
                if (typeof callback === 'function') return callback();
            },
            hideToast: function(delay = 1500, callback) {
                setTimeout(function() {
                    $("#toast").modal('hide');
                    this.isShownToast = false;
                    return typeof callback === 'function' && callback();
                }, delay || 1500);
            },
            ajaxPost: function(options) {
                $.ajax({
                    url: options.url,
                    data: options.data || "",
                    type: 'post',
                    dataType: 'json',
                    contentType: 'application/json;charset=utf-8',
                    beforeSend: function(request) {
                        let userInfo = sessionStorage.getItem("userInfo");
                        if (!!userInfo) {
                            userInfo = JSON.parse(userInfo);
                            request.setRequestHeader("token", userInfo.token);
                        }
                    },
                    success: function(res) {
                        if (res.code === 0) {
                            return typeof options['done'] === 'function' && options['done'](res.data);
                        } else if (res.code === 1001) {
                            utils.showToast(res.msg, "icon-success", true, function() {
                                sessionStorage.removeItem("userInfo");
                                location.replace("#(ctx)/");
                            });
                        } else if (res.code === 1002) {
                            utils.showToast(res.msg, "icon-warn", true, function() {
                                location.replace("#(ctx)/");
                            });
                        } else {
                            if (typeof options['fail'] === 'function') {
                                return options['fail'](res.msg);
                            } else {
                                utils.showToast(res.msg, "", true);
                            }
                        }
                    }, error: function(err) {
                        console.log(err);
                    }, complete: function() {
                        return typeof options['complete'] === 'function' && options['complete']();
                    }
                })
            }
        };
    </script>
    
    #@script()
</body>
</html>
#end
